<?php
/***************************************************************************
 *   copyright : (C) 2009 Udrea Cristian
 *   site : http://code.google.com/p/testauction-php
 ***************************************************************************/

/***************************************************************************
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as 
 *   published by the Free Software Foundation; either version 2 of the
 *   License, or (at your option) any later version. Although none of the
 *   code may be sold. If you have been sold this script, get a refund.
 ***************************************************************************/
class AuctionSold extends Element{
	public function __construct(){
		$this->attributes['AuctionID'] = 0;
	}
	public function setAuctionID($ID){
		$this->setAttribute("AuctionID", $ID);		
	}
	public function toString(){
		global $session, $auctionDB;
		$info = $auctionDB->getAuctionData($this->getAttribute('AuctionID'));
		$productinfo = $auctionDB->getProductData($info['product_id']);
		$latestoffer = $auctionDB->getAuctionLatestOffer($info['auction_id']);

		$SOLDPRICE = $auctionDB->getAuctionOfferCount($info['auction_id'])*$info['offer_increment']+$info['base_price'];
		$WINNER = $latestoffer['username'];
		$PRODUCTNAME = $productinfo['product_name']; 
		$PRODUCTPHOTOSMALL = "small_".$productinfo['pict1_url'];
		$DATECLOSED = date("j/n/Y H:i", $info['closed_timestamp']);
		
		return "<div id=\"auctionbox_".$this->getAttribute("AuctionID")."\" class=\"box_red\">".
		"<h2><a href=\"main.php?page=24&id=".$this->getAttribute("AuctionID")."\">".$PRODUCTNAME."</a></h2>".
		"<table border=\"0\" cellspacing=\"5\" cellpadding=\"0\" style=\"text-align: center\">".
		"<tr><td>&nbsp;</td>".
		"<td rowspan=\"3\" style=\"border: 2px solid black\">".
		"<a href=\"main.php?page=24&id=".$this->getAttribute("AuctionID")."\">".
		"<img src=\"produse/".$PRODUCTPHOTOSMALL."\" alt=\"".$PRODUCTNAME."\" title=\"".$PRODUCTNAME."\"/></a>".
		"</td></tr>".
		"<tr><td style=\"font-weight: bold\">Incheiata la: <p style=\"color: #1F55F0\">".$DATECLOSED."</p></td></tr>".
		"<tr><td style=\"color: #FFF000; font-weight: bold\">Cumparator:</td></tr>".
		"<tr><td colspan=\"2\" style=\"color: #FFF000; font-weight: bold\">".$WINNER."</td></tr>".
		"<tr><td><div class=\"orange-button\">VANDUT</div></td>".
		"<td style=\"font-size: 14px; font-weight: bold\">".$SOLDPRICE." CREDITS</td>".
		"</tr></table></div>";
	}
}
$auctionsold_box = new AuctionSold();
?>
